<template>
  <div id="specs_app">
    <el-table
      :data="specsList"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="ID"
        min-width="180">
      </el-table-column>
      <el-table-column
        prop="specsname"
        label="规格名称"
        min-width="180">
      </el-table-column>
      <el-table-column
        prop="attrs"
        label="规格可选值"  
        min-width="180" v-slot="props">
        <template>
            <el-button type="success" size="mini" plain v-for="(btn,index) in props.row.attrs" :key="index">{{ btn }}</el-button>
        </template>
      </el-table-column>
      <el-table-column
        prop="status"
        label="规格状态"  
        min-width="180" v-slot="props">
        <template>
          <el-button v-if="props.row.status == 1" type="success" size="mini" plain>正常</el-button>
          <el-button v-else type="danger" size="mini" plain>禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"  
        min-width="180" v-slot="props">
        <el-button size="mini" type="success" icon="el-icon-edit" circle @click="specsEdit(props.row)"></el-button>
        <el-button size="mini" type="danger" icon="el-icon-delete" circle @click="specsdelete(props.row.id)"></el-button>
      </el-table-column>
    </el-table>
    <!-- 分页部分 -->
    <el-pagination
      background
      layout="prev, pager, next"
      :page-size="size"
      :total="spaceTotal">
    </el-pagination>
  </div>
</template>

<script>
import vm from '../../vm/vm'
export default {
    props: ["specsList",'spaceTotal',"size"],
    methods: {
      specsEdit(row){
        vm.$emit("specsEdit",row)
      },
      specsdelete(id){
        //删除数据
        const url = "/specsdelete"
        this.$http.post(url,{id:id}).then(
          res => {
            this.$emit("updateSpecs")
          }
        )
      }
    },
    data() {
        return {
        }
    }
}
</script>

<style>

</style>